home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
414_01
/
comm2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-23
|
34KB
|
1,157 lines
/***********************************************************************/
/* COMM2.C - Commands E-J */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1993 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling email: M.Hessling@gu.edu.au
* 36 David Road Phone: +61 7 849 7731
* Holland Park Fax: +61 7 875 5314
* QLD 4121
* Australia
*/
/*
$Header: C:\THE\RCS\comm2.c 1.4 1993/09/01 16:25:38 MH Interim MH $
*/
#include <stdio.h>
#include "the.h"
#include "proto.h"
/*#define DEBUG 1*/
/*-------------------------- external data ----------------------------*/
extern LINE *next_line,*curr_line;
extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
extern char current_screen;
extern SCREEN_DETAILS screen[MAX_SCREENS]; /* screen structures */
extern char current_file; /* pointer to current file */
extern WINDOW *foot,*error_window;
extern bool error_on_screen;
extern char *temp_cmd;
extern char *cmd_rec;
extern unsigned short cmd_rec_len;
extern char *pre_rec;
extern unsigned short pre_rec_len;
extern char *rec;
extern unsigned short rec_len;
extern char mode_insert; /* defines insert mode toggle */
extern char in_profile; /* indicates if processing profile */
extern char in_macro;
extern char *tempfilename;
extern unsigned short file_start;
extern char curr_path[MAX_FILE_NAME+1] ;
extern char sp_path[MAX_FILE_NAME+1] ;
extern char sp_fname[MAX_FILE_NAME+1] ;
/*man-start*********************************************************************
COMMAND
emsg - display error message
SYNTAX
EMSG [message]
DESCRIPTION
The EMSG command displays an error message on the error line.
This command is usually issued from a macro file.
COMPATIBILITY
XEDIT: Does not support [mmmnnns text] option
KEDIT: Compatible
SEE ALSO
EMSG
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Emsg(char *params)
#else
int Emsg(params)
char *params;
#endif
/***********************************************************************/
{
/*-------------------------- external data ----------------------------*/
/*--------------------------- local data ------------------------------*/
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm1.c: Emsg");
#endif
display_error(0,params);
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
enter - execute a command
SYNTAX
** effective only if bound to a key **
DESCRIPTION
The ENTER command executes the command currently displayed on the
command line, if the cursor is currently displayed there.
If the key associated with ENTER is pressed while in the main or
prefix window, then the cursor will move to the first column of the
next line. If the mode is currently in 'insert', then a new line
is added and the cursor placed at the first column of the new line.
COMPATIBILITY
XEDIT: N/A
KEDIT: N/A
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Enter(char *params)
#else
int Enter(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
unsigned short x,y;
short rc=RC_OK;
register int i;
static char first=TRUE;
static char number_of_commands=0;
WINDOW *w;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm1.c: Enter");
#endif
switch(CURRENT_VIEW->current_window)
{
case WINDOW_COMMAND:
for (i=0;i<cmd_rec_len;i++)
temp_cmd[i] = cmd_rec[i];
temp_cmd[cmd_rec_len] = '\0';
strtrunc(temp_cmd);
add_command(temp_cmd);
rc = command_line(temp_cmd,COMMAND_ONLY_FALSE);
break;
case WINDOW_PREFIX:
Down_arrow((char *)"");
getyx(CURRENT_WINDOW,y,x);
wmove(CURRENT_WINDOW,y,0);
break;
case WINDOW_MAIN:
/* check for insert mode or not */
if (mode_insert)
{
post_process_line(CURRENT_VIEW->focus_line);
insert_new_line((char *)"",0,1,get_true_line(),FALSE,FALSE);
}
else
{
Down_arrow((char *)"");
getyx(CURRENT_WINDOW,y,x);
wmove(CURRENT_WINDOW,y,0);
}
break;
}
#ifdef TRACE
trace_return();
#endif
return(rc);
}
/*man-start*********************************************************************
COMMAND
expand - expand tab characters to spaces
SYNTAX
EXPand [target]
DESCRIPTION
The EXPAND command converts all tab characters to spaces depending
on the size of a tab determined by [SET] TABS command.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Expand(char *params)
#else
int Expand(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
#define EXP_PARAMS 1
char *word[EXP_PARAMS+1];
char parm[EXP_PARAMS];
register int i;
unsigned short num_params;
long num_lines,true_line;
unsigned short x,y;
int direction;
LINE *curr;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm3.c: Expand");
#endif
/*---------------------------------------------------------------------*/
/* Validate the parameters that have been supplied. */
/* If no parameter is supplied, 1 is assumed. */
/*---------------------------------------------------------------------*/
num_params = param_split(params,word,EXP_PARAMS,WORD_DELIMS,TEMP_PARAM);
if (num_params == 0)
{
num_params = 1;
word[0] = (char *)"1";
}
if (equal((char *)"all",word[0],3))
true_line = 1L;
else
true_line = get_true_line();
if ((num_lines = valid_target(word[0],true_line)) == TARGET_ERROR)
{
display_error(4,(char *)word[0]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
if (num_lines == TARGET_NOT_FOUND)
{
display_error(17,(char *)"");
#ifdef TRACE
trace_return();
#endif
return(RC_TARGET_NOT_FOUND);
}
/*---------------------------------------------------------------------*/
/* Determine in which direction we are working. */
/*---------------------------------------------------------------------*/
if (num_lines < 0)
{
dir